package cn.yzx.pethome.system.echarts.controller;

import cn.yzx.pethome.system.dept.domain.DepartmentBo;
import cn.yzx.pethome.system.dept.service.IDepartmentService;
import cn.yzx.pethome.system.shop.domain.ShopBo;
import cn.yzx.pethome.system.shop.service.IShopService;
import cn.yzx.pethome.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/echars")
@Api(value  = "部门的API",description="部门相关的CRUD功能")
public class EcharsController {
    @Autowired
    private IShopService shopService;
    @Autowired
    public IDepartmentService departmentService;

    @ApiOperation(value  = "统计每月注册的员工数量")
    @PostMapping("/countByTime")
    public AjaxResult countByTime(){
        try {
            List<ShopBo> shops = shopService.countByData();
            return AjaxResult.success().setData(shops);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.error();
    }
    @ApiOperation(value  = "统计部门员工数量")
    @PostMapping("/countByEmp")
    public AjaxResult countByEmp(){
        try {
            List<DepartmentBo> depts = departmentService.countByEmp();
            return AjaxResult.success().setData(depts);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.error();
    }
}